package com.clouddms.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 首页控制器
 *
 * @author Cloud-DMS Team
 * @version 1.0.0
 */
@Controller
public class IndexController {

    /**
    * 登录首页 (重定向到认证控制器)
    * */
    @GetMapping("/login")
    public String login(Model model) {
        return "redirect:/auth/login";
    }

    /**
     * 系统首页 (重定向到认证控制器处理)
     */
    @GetMapping("/console")
    public String index(Model model) {
        return "redirect:/auth/console";
    }

    /**
     * 系统状态检查API
     */
    @GetMapping("/api/status")
    @ResponseBody
    public Object getSystemStatus() {
        return new Object() {
            public String status = "running";
            public String message = "Cloud-DMS系统运行正常";
            public String version = "1.0.0";
            public String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            public Object modules = new Object() {
                public boolean userAuth = false;        // 用户认证模块
                public boolean permissionMgmt = false;  // 权限管理模块
                public boolean securityEncrypt = true;
                public boolean networkTransfer = true;
                public boolean storageMgmt = false;     // 存储管理模块
                public boolean backupRecover = false;   // 备份恢复模块
                public boolean lifecycleMgmt = false;   // 文件生命周期模块
                public boolean dataRecover = false;     // 数据恢复模块
            };
        };
    }

    /**
     * 健康检查
     */
    @GetMapping("/health")
    @ResponseBody
    public Object healthCheck() {
        return new Object() {
            public String status = "In Progress";
            public String message = "系统开发中... (所见内容均为Mock效果)";
            public String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        };
    }
}